<template>
	<view class="u-p-t-46">
		<view class="d u-p-t-60 u-p-l-26 u-p-r-12 u-p-b-74 u-flex-col">
			  <text class="u-font-38 col333 u-m-b-26">输入邀请码</text>
			  <u-input
			    placeholder="请输入邀请码"
			    v-model="value"
				clearable
				class="input"
				placeholderStyle="font-size: 56rpx;color: #E4E5E9;font-weight: 500;"
			  ></u-input>
		</view>
		<view class="btn u-font-34 u-flex u-row-center" hover-class="hover-btn" @click="onJoin">
			<text>确认加入</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				istjr: ''
			};
		},
		onLoad(option) {
			console.log(option.istjr)
			 this.istjr = option.istjr
			 this.tojoin()
		},
		methods: {
			tojoin() {
				if(this.istjr == 0) {
					this.$toast("请先输入邀请码")
				}
			},
			onJoin() {
				if(this.value.length <= 0) {
					return this.$toast('请输入邀请码')
				}
				this.myhttp({
					url: '?s=/api/User/postSuperior',
					data: {
						tjr_id: this.value
					}
				}).then(res => {
					this.$toast(res.data.msg)
					if (res.data.code == 1) {
						setTimeout(function(){
							let pages = getCurrentPages();  //获取所有页面栈实例列表
							let nowPage = pages[ pages.length - 1];  //当前页页面实例
							let prevPage = pages[ pages.length - 2 ];  //上一页页面实例
							prevPage.$vm.sh = 100;   //修改上一页data里面的sh参数值为100
							uni.navigateBack({  //uni.navigateTo跳转的返回，默认1为返回上一级
							    delta: 1,
								animationType: 'pop-out',
								animationDuration: 200
							});
						},1500)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.d {
		width: 694upx;
		height: 280upx;
		background: #FFFFFF;
		box-shadow: 0upx 50upx 100upx 0upx rgba(212, 212, 212, 0.2);
		border-radius: 20upx;
		margin: auto;
	}
	.btn {
		position: fixed;
		width: 625upx;
		height: 69upx;
		background: #333333;
		color: #FFFFFF;
		border-radius: 50rpx;
		bottom: 10%;
		left: 50%;
		font-size: 13px;
		-webkit-transform: translateX(-50%);
		transform: translateX(-50%);
	}
	.hover-btn {
		background-color: rgba(0, 0, 0, .1);
	}
	.u-input {
		border-bottom: 1px solid #dcdfe6;
	}
	.col333 {
		color: #333333;
	}
</style>
